{extend name="platform/base" /} 
{block name="main"}
<section class="panel panel-default">
	<header class="panel-heading font-bold"> 添加类型 </header>
	<div class="panel-body">
		<form class="form-horizontal" id="addreporttype_form" name="form">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="color-red">*</span>举报类型</label>
				<div class="col-md-2">
					<input type="text" class="form-control" id="inform_type_name" onkeydown="error_hide()" name="inform_type_name"  value="">
				</div>
				<p class="error">请输入举报类型</p>
			</div>
			<div class="line line-dashed line-lg pull-in"></div> 
			
			<div class="form-group">
				<label class="col-sm-2 control-label">状态</label>
				<div class="col-sm-2">
					<label class="switch"><input id="inform_type_state" type="checkbox"><span></span></label>
				</div>
			</div>			
			<div class="line line-dashed line-lg pull-in"></div>

			
			<div class="form-group">
				<label class="col-sm-2 control-label">描述</label>
				<div class="col-sm-4">
					<div id="editor" class="form-control" style="overflow: scroll; height: 150px;"></div>
				</div>
			</div>
			<!-- 书签 -->
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<div class="col-sm-4 col-sm-offset-2">

					<a href="javascript:void(0);" onclick="addReportTypeAjax()" class="btn btn-primary">保存</a>
				</div>
			</div>
		</form>
	</div>
</section>
<script>
	/* $().ready(function() {
		$("#addreporttype_form").validate({
			submitHandler : function() {
				addReportTypeAjax();
			}
		});
	}); */
	/**
	 *添加模块
	 */
	function addReportTypeAjax() {
		var inform_type_name = $("#inform_type_name").val();
		var inform_type_desc = $("#editor").html();
		
		if ($("#inform_type_state").prop("checked")) {
			var inform_type_state = 1;
		} else {
			var inform_type_state = 2;
		}
		
		if($.trim(inform_type_name) == ''){
			$("#inform_type_name").focus().parent().next().show();
			return;
		}
		
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/report/addreporttype')}",
			data : {
				'inform_type_name' : inform_type_name,
				'inform_type_state' : inform_type_state,
				'inform_type_desc' : inform_type_desc
			},
			async : true,
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],'{:__URL("PLATFORM_MAIN/report/reporttypelist")}');
				} else {
					showMessage('error', data["message"]);
				}
			}
		});
	}

</script>
{/block}